package activity

import (
	"gq_volunteer_platform/bean"
	"gq_volunteer_platform/model/activity"

	"github.com/gin-gonic/gin"
)

// AllTypeList 获取所有活动类型列表
func AllTypeList(c *gin.Context) {

	var list []struct {
		ID   uint
		Name string
	}

	var tx = bean.MysqlDb.Model(&activity.ActivityType{})

	// 查询列表
	if err := tx.Order("`sort` ASC").Find(&list).Error; err != nil {
		bean.Log.Error(err)
		c.String(500, err.Error())
		return
	}

	c.PureJSON(200, gin.H{
		"list": list,
	})
}
